import Vue from 'vue'
import App from './App.vue'
import router from './router/index'
import store from './store/index'
import filters from './filters'
import api from './api/install'
import axios from './api/axios'
import local from '@/utils/localStorage'
import NProgress from 'nprogress'// 引入nprogress
import 'nprogress/nprogress.css' // 这个样式必须引入

import 'element-ui/lib/theme-chalk/index.css';
import '@/assets/less/lib/theme.less'
// import '@/assets/less/lib/element-variables.less'
import '@/assets/less/main.less'
import Bus from './bus/bus.js'
import config from '@/config'
import elementUI from 'element-ui'
import './permission' // permission control
import '@/utils/shortcut'
import permissions from '@/directive/permission/index.js' // 权限判断指令
import { permission } from '@/directive/permission/permission.js' // 权限判断函数
import adaptive from '@/directive/adaptive/index.js' // el-table高度自适应
import './directive/preventReClick' // 防多次点击，重复提交
import './directive/selectLoadmore' // select下拉加载更多
import '@/mixins'
import components from '@/views/components'
import comps from '@/components'


import './mock'
// import 'umy-ui/lib/theme-chalk/index.css'// 引入UmyUi样式

// 引入UmyUi用于解决表单加载卡顿问题
// import {
//     UTableColumn,
//     UTable,
//     UxGrid,
//     UxTableColumn
// } from 'umy-ui'
// Vue.use(UTableColumn)
// Vue.use(UTable)
// Vue.use(UxGrid)
// Vue.use(UxTableColumn)

// 简单配置nprogress
NProgress.inc(0.2)
NProgress.configure({ easing: 'ease', speed: 500, showSpinner: false })
router.beforeEach((to, from, next) => {
    NProgress.start()
    next()
})

router.afterEach(() => {
    NProgress.done()
})

// 注册全局组件
Object.keys(components).forEach(key => {
    Vue.component(key, components[key])
})
Object.keys(comps).forEach(key => {
    Vue.component(key, comps[key])
})
// 全局注册权限
Vue.prototype.$permission = permission // 注册全局权限函数
Vue.use(permissions) // 使用全局权限指令
Vue.use(adaptive)

Vue.prototype.$bus = Bus
Vue.prototype.$config = config
Vue.prototype.$http = axios
Vue.use(elementUI)
Vue.use(api)
Vue.use(local)
Vue.config.productionTip = false
if (process.env.NODE_ENV !== 'production') {
    // 使用 performance 开启性能追踪
    Vue.config.performance = true
}
Vue.prototype.hf = function (url, cu) { // 路由跳转
    router.push({ path: '/' + url, query: cu })
}
// 全局过滤器
Object.keys(filters).forEach(filterName => {
    Vue.filter(filterName, filters[filterName])
})

new Vue({
    router,
    store,
    render: h => h(App)
}).$mount('#app')
